package com.fz.service;

import com.fz.entity.Student;
import com.fz.mapper.StudentMapper;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * Created by Z-C-Y on 2018-02-01.
 */
public class StudentService implements StudentMapper{
    protected StudentMapper studentMapper;
    protected SqlSession session;
    public StudentService(){
      session = new Util().getSession();
      studentMapper = session.getMapper(StudentMapper.class);
    }

    /*得到数据库中student表中的数据*/
    public List<Student> queryAll() {
        return studentMapper.queryAll();
    }

    /*根据id进行删除数据*/
    public int deleteById(int id) {
        int i =studentMapper.deleteById(id);
        session.commit();/*这是提交数据*/
        return i;
    }

    public Object add(String name) {

        return studentMapper.add(name);
    }
}
